package com.oocl.communicator.impl;

import java.io.IOException;
import java.io.PrintWriter;

import com.oocl.communicator.Sender;
import com.oocl.constant.LogLevel;
import com.oocl.pojo.Protocol;
import com.oocl.util.ConsoleLogUtil;
import com.oocl.util.JsonUtil;

public class SenderImpl implements Sender {
	private PrintWriter out;
	
	public SenderImpl(PrintWriter out) {
		this.out = out;
	}

	@Override
	public void send(Protocol protocol)
			throws IOException {
		out.println(JsonUtil.toJsonObject(protocol).toString());
		out.flush();
		ConsoleLogUtil.log("server send a Protocol package! "+protocol, LogLevel.INFO);
	}

}
